//
//  UIBarButtonItem+Category.swift
//  XMGWB
//
//  Created by 李南江 on 15/9/6.
//  Copyright © 2015年 xiaomage. All rights reserved.
//

import UIKit

extension UIBarButtonItem
{
    
    
//    var isBack:Bool = false
//    
//    if isBack {
//    let imageName = "navigationbar_friendattention"
//    btn.setImage(UIImage(named: imageName), for: UIControlState(rawValue: 0))
//    btn.setImage(UIImage(named: imageName + "_highlighted"), for: UIControlState(rawValue: 0))
    
    class func crateBarButtonItem(_ imageName:String, target: AnyObject?, action: Selector) -> UIBarButtonItem
    {
        let btn = UIButton()
        btn.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
        btn.setImage(UIImage(named: imageName), for: UIControlState())
        btn.setImage(UIImage(named: imageName + "_highlighted"), for: UIControlState.highlighted)
        btn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        
        return UIBarButtonItem(customView: btn)
       
        
    }
}
